using System;
using System.Configuration;
using System.Data;
using MySql.Data.MySqlClient;


namespace DomesticBank.Models {
	public class Core {
		protected static Core instance;
		protected string databaseString;
		protected MySqlConnection connection;
		
		
		public static Core Instance {
			get {
				if(Core.instance == null) {
					Core.instance = new Core();
				}
				
				return Core.instance;
			}
		}
		
		
		protected Core() {
			this.databaseString = ConfigurationManager.AppSettings["Database"];
		}
		
		
		public void openConnection() {
			if(this.connection == null) {
				this.connection = new MySqlConnection(this.databaseString);
			}
			
			this.connection.Open();
		}
		
		
		public void closeConnection() {
			this.connection.Close();
		}
		
		
		public MySqlConnection getConnection() {
			this.openConnection();
			return this.connection;
		}
	}
}